import { SecurityService } from '../services/securityService.js'

async function runSecurityScanner() {
  console.log('🔍 Starting security scanner...')
  
  try {
    const securityService = new SecurityService()
    await securityService.scanPendingPlugins()
    console.log('✅ Security scanner completed successfully')
  } catch (error) {
    console.error('❌ Security scanner failed:', error)
    process.exit(1)
  }
}

// 如果直接运行此脚本
if (import.meta.url === `file://${process.argv[1]}`) {
  runSecurityScanner()
    .catch((error) => {
      console.error('Fatal error:', error)
      process.exit(1)
    })
    .finally(async () => {
      // 优雅关闭
      process.exit(0)
    })
}

export { runSecurityScanner }
